package cn.rwklyd.BookKeeping.pojo.vo;

import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.math.BigDecimal;
import java.util.List;

@Data
@Schema(description = "交易记录分页视图对象（包含统计数据）")
public class TransactionPageVO {
    @Schema(description = "交易记录列表")
    private List<TransactionVO> records;
    
    @Schema(description = "总记录数")
    private long total;
    
    @Schema(description = "每页大小")
    private long size;
    
    @Schema(description = "当前页码")
    private long current;
    
    @Schema(description = "总页数")
    private long pages;
    
    @Schema(description = "查询时间范围内的总收入")
    private BigDecimal totalIncome;
    
    @Schema(description = "查询时间范围内的总支出")
    private BigDecimal totalExpense;
    
    @Schema(description = "查询时间范围内的收支差额")
    private BigDecimal totalBalance;
    
    /**
     * 从IPage转换
     */
    public static TransactionPageVO fromIPage(IPage<TransactionVO> page) {
        TransactionPageVO vo = new TransactionPageVO();
        vo.setRecords(page.getRecords());
        vo.setTotal(page.getTotal());
        vo.setSize(page.getSize());
        vo.setCurrent(page.getCurrent());
        vo.setPages(page.getPages());
        return vo;
    }
} 